/**
 * 
 */
import CryptoJS from 'crypto-js';
export function decrypt_obj(content) {
  var key = CryptoJS.enc.Utf8.parse('bonc_mobile_jf00');
  var iv = CryptoJS.enc.Utf8.parse('16-Bytes--bonc00');
  var bytes = CryptoJS.AES.decrypt(content, key, { iv: iv, mode: CryptoJS.mode.CBC });
  var plaintext = bytes.toString(CryptoJS.enc.Utf8);
  if (plaintext == "" || plaintext == null)
    return "";
  return eval('(' + plaintext + ')');
}
function decrypt_str(content) {
  var key = CryptoJS.enc.Utf8.parse('bonc_mobile_jf00');
  var iv = CryptoJS.enc.Utf8.parse('16-Bytes--bonc00');
  var bytes = CryptoJS.AES.decrypt(content, key, { iv: iv, mode: CryptoJS.mode.CBC });
  var plaintext = bytes.toString(CryptoJS.enc.Utf8);
  return plaintext;
}

function guid() {
  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
    var r = Math.random() * 16 | 0,
      v = c == 'x' ? r : (r & 0x3 | 0x8);
    return v.toString(16);
  });
}
function sysAppOd(uniqueId, operation, moduleName, moduleChildOne, moduleChildTwo, menuCode) {
  var obj = {};
  obj.uniqueId = uniqueId;
  obj.operation = operation;
  obj.moduleName = moduleName;
  obj.moduleChildOne = moduleChildOne;
  obj.moduleChildTwo = moduleChildTwo;
  obj.menuCode = menuCode;

  var u = navigator.userAgent;
  var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
  if (isiOS) {
    obj.appPlatform = 'IOS';
    localStorage.setItem('sysAppOd', JSON.stringify(obj));
    getSid(sysAppOdSave);
  } else {
    obj.appPlatform = 'Android';
    obj.sid = getSid();
    localStorage.setItem('sysAppOd', JSON.stringify(obj));
    sysAppOdSave();
  }
}
function sysAppOdSave(sid) {
  var obj = JSON.parse(localStorage.getItem('sysAppOd'));
  if (sid) {
    obj.sid = sid;
  }
  $.ajax({
    url: cxt + "/appPortal/sysAppOd.do",
    type: "POST",
    data: {
      formJson: JSON.stringify(obj),
      token: token
    },
    success: function (data) {
    }
  })

}